home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gp_win32.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.6 KB  |  121 lines

  1. /* Copyright (C) 1992, 1993, 1994, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gp_win32.c,v 1.2 2000/09/19 19:00:25 lpd Exp $ */
  20. /* Common platform-specific routines for MS-Windows WIN32 */
  21. /* originally hacked from gp_msdos.c by Russell Lang */
  22. #include "malloc_.h"
  23. #include "stdio_.h"
  24. #include "string_.h"        /* for strerror */
  25. #include "dos_.h"
  26. #include "gstypes.h"
  27. #include "gsmemory.h"        /* for gp.h */
  28. #include "gserror.h"
  29. #include "gserrors.h"
  30. #include "gp.h"
  31. #include "windows_.h"
  32.  
  33. /* ------ Miscellaneous ------ */
  34.  
  35. /* Get the string corresponding to an OS error number. */
  36. /* This is compiler-, not OS-, specific, but it is ANSI-standard and */
  37. /* all MS-DOS and MS Windows compilers support it. */
  38. const char *
  39. gp_strerror(int errnum)
  40. {
  41.     return strerror(errnum);
  42. }
  43.  
  44. /* ------ Date and time ------ */
  45.  
  46. /* Read the current time (in seconds since Jan. 1, 1980) */
  47. /* and fraction (in nanoseconds). */
  48. void
  49. gp_get_realtime(long *pdt)
  50. {
  51.     SYSTEMTIME st;
  52.     long idate;
  53.     static const int mstart[12] = {
  54.     0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
  55.     };
  56.  
  57.     /* This gets UTC, not local time */
  58.     /* We have no way of knowing the time zone correction */
  59.     GetSystemTime(&st);
  60.     idate = (st.wYear - 1980) * 365 +    /* days per year */
  61.     ((st.wYear - 1) / 4 - 1979 / 4) +    /* intervening leap days */
  62.     (1979 / 100 - (st.wYear - 1) / 100) +
  63.     ((st.wYear - 1) / 400 - 1979 / 400) +
  64.     mstart[st.wMonth - 1] +    /* month is 1-origin */
  65.     st.wDay - 1;        /* day of month is 1-origin */
  66.     idate += (2 < st.wMonth
  67.           && (st.wYear % 4 == 0
  68.           && (st.wYear % 100 != 0 || st.wYear % 400 == 0)));
  69.     pdt[0] = ((idate * 24 + st.wHour) * 60 + st.wMinute) * 60 + st.wSecond;
  70.     pdt[1] = st.wMilliseconds * 1000000;
  71. }
  72.  
  73. /* Read the current user CPU time (in seconds) */
  74. /* and fraction (in nanoseconds).  */
  75. void
  76. gp_get_usertime(long *pdt)
  77. {
  78.     gp_get_realtime(pdt);    /* Use an approximation for now.  */
  79. }
  80.  
  81. /* ------ Console management ------ */
  82.  
  83. /* Answer whether a given file is the console (input or output). */
  84. /* This is not a standard gp procedure, */
  85. /* but the MS Windows configuration needs it, */
  86. /* and other MS-DOS configurations might need it someday. */
  87. int
  88. gp_file_is_console(FILE * f)
  89. {
  90. #ifdef __DLL__
  91.     if (f == NULL)
  92.     return 1;
  93. #else
  94.     if (f == NULL)
  95.     return 0;
  96. #endif
  97.     if (fileno(f) <= 2)
  98.     return 1;
  99.     return 0;
  100. }
  101.  
  102. /* ------ Screen management ------ */
  103.  
  104. /* Get the environment variable that specifies the display to use. */
  105. const char *
  106. gp_getenv_display(void)
  107. {
  108.     return NULL;
  109. }
  110.  
  111. /* ------ File names ------ */
  112.  
  113. /* Define the default scratch file name prefix. */
  114. const char gp_scratch_file_name_prefix[] = "_temp_";
  115.  
  116. /* Define the name of the null output file. */
  117. const char gp_null_file_name[] = "nul";
  118.  
  119. /* Define the name that designates the current directory. */
  120. const char gp_current_directory_name[] = ".";
  121.